{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "kxu1Gfhx1pHg"
   },
   "source": [
    "<a href=\"https://colab.research.google.com/github/jeffheaton/app_generative_ai/blob/main/t81_559_class_12_3_persona.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ZbNbAV281pHh"
   },
   "source": [
    "# T81-559: Applications of Generative Artificial Intelligence\n",
    "**Module 12: Prompt Engineering**\n",
    "* Instructor: [Jeff Heaton](https://sites.wustl.edu/jeffheaton/), McKelvey School of Engineering, [Washington University in St. Louis](https://engineering.wustl.edu/Programs/Pages/default.aspx)\n",
    "* For more information visit the [class website](https://sites.wustl.edu/jeffheaton/t81-558/)."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {
    "id": "HwnvSYEQ1pHi"
   },
   "source": [
    "# Module 12 Material\n",
    "\n",
    "Module 12: Prompt Engineering\n",
    "\n",
    "* Part 12.1: Intro to Prompt Engineering [[Video]](https://www.youtube.com/watch?v=p8q2kFhyX3M&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_1_prompt_engineering)\n",
    "* Part 12.2: Few Shot and Chain of Thought [[Video]](https://www.youtube.com/watch?v=Bj-zOiqpp6g&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_2_fewshot_cot.ipynb)\n",
    "* **Part 12.3: Persona and Role Patterns** [[Video]](https://www.youtube.com/watch?v=uD9z3LFw7nA&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_3_persona.ipynb)\n",
    "* Part 12.4: Question, Refinement and Verification Patterns [[Video]](https://www.youtube.com/watch?v=UF0gN79hg4g&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_4_refinement_eval.ipynb)\n",
    "* Part 12.5: Content Creation and Structured Prompt Patterns [[Video]](https://www.youtube.com/watch?v=PPNnTDfKjPE&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_5_create.ipynb)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "v2MPPX0c1pHi"
   },
   "source": [
    "# Part 12.3: Persona and Role Patterns\n",
    "\n",
    "Patterns for Large Language Models (LLMs) are structured techniques or templates used when crafting prompts to elicit specific types of responses from the AI. These patterns guide the model's output by setting up particular scenarios, roles, or instructions within the prompt. By utilizing patterns such as personas, role-playing, or semantic filters, users can effectively steer the conversation, making the AI's responses more relevant, coherent, and tailored to specific needs or contexts. This approach enhances the interaction with LLMs, enabling more precise and meaningful communication.\n",
    "\n",
    "In this part, we'll explore how to craft interactions with Generative AI using personas, roles, and tailored conversations based on defined identities within the life insurance context. Mastering these patterns will enable you to create more engaging and effective prompts, resulting in richer and more meaningful AI responses related to life insurance.\n",
    "\n",
    "### Persona Pattern\n",
    "The Persona Pattern involves assigning a specific character or identity to the AI, guiding it to respond from that perspective. This technique helps shape the tone, style, and content of the AI's replies.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "You are an experienced life insurance agent specializing in family policies. Explain to a new client the benefits of whole life insurance.\n",
    "```\n",
    "\n",
    "### Audience Persona\n",
    "The Audience Persona focuses on tailoring the AI's response to suit a particular audience. By specifying who the information is for, you can ensure the content is appropriate and engaging for that group.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Explain the importance of life insurance to a recent college graduate who has just entered the workforce.\n",
    "```\n",
    "\n",
    "### Role-Playing Prompts\n",
    "Role-Playing Prompts engage the AI in a simulated scenario where it takes on a specific role, allowing for dynamic and context-rich interactions.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "You are a client interested in purchasing a life insurance policy. Initiate a conversation with an insurance agent, expressing your concerns and asking about policy options.\n",
    "```\n",
    "\n",
    "### Flipped Interaction Pattern\n",
    "The Flipped Interaction Pattern reverses the typical roles, asking the AI to lead the conversation or pose questions to you. This can stimulate critical thinking and active engagement.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "You are my financial advisor. Ask me questions to help determine the best life insurance plan for my needs.\n",
    "```\n",
    "\n",
    "### Game Play Pattern\n",
    "The Game Play Pattern transforms the interaction into a game, making the exchange more interactive and entertaining.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Let's play a quiz game about life insurance terms. Ask me five multiple-choice questions to test my knowledge.\n",
    "```\n",
    "\n",
    "### Instructional Prompts\n",
    "Instructional Prompts direct the AI to provide clear, step-by-step instructions or explanations on a particular topic or process.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Provide a step-by-step guide on how to file a life insurance claim after the loss of a loved one.\n",
    "```\n",
    "\n",
    "### Combining Patterns\n",
    "Combining Patterns involves using two or more prompt strategies together to create complex and nuanced interactions.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Assume the persona of a retirement planning expert (Persona Pattern) and explain to a couple in their 50s (Audience Persona) how life insurance can be a part of their retirement strategy.\n",
    "```\n",
    "\n",
    "### Semantic Filter Pattern\n",
    "The Semantic Filter Pattern instructs the AI to include or exclude specific content based on meaning, ensuring responses meet particular criteria or avoid certain topics.\n",
    "\n",
    "Example Prompt:\n",
    "\n",
    "```\n",
    "Summarize the key features of term life insurance policies, focusing only on benefits for young families and excluding any discussion of investment components.\n",
    "```\n",
    "\n",
    "By utilizing these patterns within the life insurance context, you can effectively steer AI interactions to be more personalized, engaging, and suitable for your intended purpose. Practice crafting prompts with these techniques to enhance your proficiency in working with Generative AI in the field of life insurance.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
